class Solution {
    public int maximumDifference(int[] nums) {
        int left = nums[0];
        int ans = -1;
        int div;
        for (int i = 1; i < nums.length; i++) {
            div = nums[i] - left;
            if (div > 0)
                ans = Math.max(ans, div);
            left = Math.min(left, nums[i]);
        }
        return ans;
    }
}